// pages/announcementdetails/index.js
const app = getApp()  // 引入app
const _request = require("../../utils/request.js"); // 引入require;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    marginBottom: app.globalData.marginBottom,
    imgUrl: app.globalData.imgUrl, //全局img路径
    detail:{},
    path:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // 获取详情
    _request.get('/bulletin/findBulletin', {
      userId: wx.getStorageSync('userid'),
      id: options.id
    }, 'modules').then((res) => {
      res.data.data.createtime = getTime(res.data.data.createtime, 6)
      res.data.data.desc = res.data.data.desc.replace(/↵/g, "/n")
      this.setData({
        msgObj: res.data.data
      })
    }).catch((error) => {
      console.log(error, 'error');
    })
  },

  timestampToTime: function (timestamp) {
    var date = new Date(timestamp);
    var YY = date.getFullYear() + '-';
    var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
    return YY + MM + DD;
  }
})